
interface GenericArray<T> {
    filter(
        callbackfn: (value: T, index: number, array: T[]) => any,
        thisArg?: any
    ): T[]

    map<U>(
        callbackfn: (value: T, index: number, array: T[]) => U,
        thisArg?: any
    ): U[]
}


class MyGeneric<T>{
    private array: Array<T> = []

    constructor() {
    }

    add(v: T): boolean {
        let len = this.array.push(v)
        return len > 0 ? true : false
    }

    show(){
        console.log(this.array);
    }
}

function genericApp(){
    let test = new MyGeneric<string|number>()
    test.add(111)
    test.add("222")
    test.show()
}

genericApp()